﻿using System;
using System.Linq;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.Networking;

public static class PlayerExtension
{
    public static GameObject GetPlayer(this NetworkConnection conn)
    {
        PlayerController controller = conn.playerControllers.ElementAtOrDefault<PlayerController>(0);
        return ((controller == null) ? null : controller.gameObject);
    }

    public static GameObject GetPlayerCharacter(this NetworkConnection conn)
    {
        PlayerController controller = conn.playerControllers.ElementAtOrDefault<PlayerController>(1);
        return ((controller == null) ? null : controller.gameObject);
    }

    public static bool IsPlayer(this Collider co)
    {
        return (co.tag == GameTags.Player);
    }

    public static bool IsPlayer(this GameObject go)
    {
        return (go.tag == GameTags.Player);
    }
}

